<template>
	<view class="container">
		<form @submit="formSubmit" @reset="formReset">
			<view class="my-add-bank-card-box">
				<view class="floor">
					<view class="title">
						 派单人员
					</view>
					<view class="content">
						<input class="popup-input-field" name="repairUserName" type="text"
							v-model="address.repairUserName" placeholder="请填写派单人员姓名" />
					</view>
				</view>
				<view class="floor">
					<view class="title">
						维修资材
					</view>
					<view class="content">
						<input class="popup-input-field" name="repairMaterials" type="text" v-model="address.repairMaterials"
							placeholder="填写维修资材" />
					</view>
				</view>
				<view class="floor">
					<view class="title">
						派工时间
					</view>
					<view class="content">
						<input class="popup-input-field" name="number" type="number"
							v-model="address.appTime" placeholder="请填写派工时间" />
					</view>
				</view>
				<view class="floor">
					<view class="title">
						维修完成时间
					</view>
					<view class="content">
						<input class="popup-input-field" name="repairDate" type="number" v-model="address.repairDate"
							placeholder="请填写维修完成时间" />
					</view>
				</view>
				<button type="primary" style="width: 80%;margin: 20px auto;" click="submit">提交</button>
			</view>
		</form>
		
		<!-- <view class="floor">
			<view class="title">派单人员</view>
			<input v-model="repairUserName"/>
		</view>
		<view class="floor">
			<view class="title">电话</view>
			<view class="content">13341231234</view>
		</view>
		<view class="floor">
			<view class="title">报修内容</view>
			<view class="content">修水表修水表修水表修水表修水表修水表修水表修水表修水表修水表</view>
		</view>
		<view class="floor" style="border: none;">
			<view class="title">用户图片</view>
			<view class="content picList">
				<image v-for="(item,index) in picList" :src="item" @click="previewPic(item,index)"></image>
			</view>
		</view>
		<view class="floor">
			<view class="title">处理结果</view>
			<view class="content">
				<picker @change="bindPickerChange" :value="index" :range="array">
					<view class="uni-input">{{array[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="floor" style="border: none;">
			<view class="title">维修图片(长按可删除)</view>
			<view class="content picList">
				<image v-for="(item,index) in picList2" :src="item" @click="previewPic(item,index)"></image>
				<button @click="addPic">+</button>
			</view>
		</view> -->
		
	</view>
</template>

<script>
	import {
		flowRepairEdit
	} from "@/api/home.js"
	export default {
		data() {
			return {
				address: {},
				picList: [
					"/static/60x60.png",
					"/static/c1.png",
					"/static/c2.png",
					"/static/60x60.png",
					"/static/c1.png",
					"/static/c2.png"
				],
				picList2: [],
				array: ['已处理', '无法维修'],
				index: 0,
				dict:{}
			}
		},
		onLoad(t) {
			this.dict = JSON.parse(t.detail);
		},
		methods: {
			submit() {
				var data = this.address
				flowRepairEdit(data).then(res => {
					uni.stopPullDownRefresh();
					if(res.code == 200){
						console.log('提交成功')
						// 返回上一页
						uni.navigateBack({
						    delta: 1 // 默认值是1，表示返回的页面层数
						});
					}
				}).catch(err=>{
					console.log('提交失败')
				})
			},
			// bindPickerChange: function(e) {
			// 	console.log('picker发送选择改变，携带值为', e.detail.value)
			// 	this.index = e.detail.value
			// },
			// addPic() {
			// 	var that = this;
			// 	uni.chooseImage({
			// 		success(res) {
			// 			console.log(res);
			// 			var arr = res.tempFilePaths;
			// 			for (var i = 0; i < arr.length; i++) {
			// 				that.picList2.push(arr[i]);
			// 			}
			// 		}
			// 	})
			// },
			// previewPic(item, index) {
			// 	var that = this;
			// 	uni.previewImage({
			// 		urls: that.picList,
			// 		current: index
			// 	})
			// }
		}
	}
</script>

<style lang="scss" scoped>
	uni-input {
		height: 70rpx !important;
		line-height: 70rpx !important;
	}

	.floor {
		width: 100%;
		overflow: hidden;
		margin-bottom: 5px;

		.title {
			float: left;
			width: 120px;
			line-height: 70rpx;
			text-align: center;
			font-size: 28rpx;
			color: #666666;
			background-color: #fff;
		}

		.content {
			float: left;
			width: calc(100% - 130px);
			height: 70rpx;
			line-height: 70rpx;
			border-bottom: 1px solid #ccc;

			uni-button {
				width: 50px;
				height: 50px;
				display: block;
				float: left;
				margin: 10px;
			}

			uni-image {
				width: 50px;
				height: 50px;
				display: block;
				float: left;
				margin: 10px;
			}
		}
	}
</style>